package com.zyh.material_code_input.slice;

import com.github.glomadrian.codeinputlib.CodeInput;
import com.zyh.material_code_input.ResourceTable;
import com.zyh.material_code_input.ToastsUtils;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

import java.util.Arrays;

public class MainAbilitySlice extends AbilitySlice{

    private CodeInput inputCode;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        getWindow().setStatusBarColor(Color.getIntColor("#222222"));
        inputCode = (CodeInput) findComponentById(ResourceTable.Id_inputCode1);
        inputCode.setCodeReadyListener(new CodeInput.codeReadyListener(){

            @Override
            public void onCodeReady(Character[] code) {
                new ToastsUtils.Builder(getContext())
                    .setToastText("code entered is : "+ Arrays.toString(code)).setDuration(2000)
                    .build().show();
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

}
